//
//  triangle_v3.h
//  OpenLearn
//
//  Created by korion chen on 2020/3/15.
//  Copyright © 2020 korion. All rights reserved.
//

#ifndef triangle_v3_h
#define triangle_v3_h
#include <stdint.h>
#include <GLFW/glfw3.h>

class TriangleV3 {

private:
    static const float vertices[18];

    const char* vertex_shader_code = ""
        "#version 330 core\n"
        "layout (location = 0) in vec3 aPos;\n"
        "layout (location = 1) in vec3 aColor;\n"
        "out vec3 ourColor;\n"
        "void main()\n"
        "{\n"
        "   gl_Position = vec4(aPos, 1.0);\n"
        "   ourColor = aColor;\n"
        "}\n";

    const char* fragment_shader_code = ""
        "#version 330 core\n"
        "in vec3 ourColor;\n"
        "out vec4 FragColor;\n"
        "void main()\n"
        "{\n"
        "   FragColor = vec4(ourColor, 1.0);\n"
        "}\n";

    int mProgram;

    uint32_t VBO;
    
    uint32_t VAO;
    
    int createShader(int type, const char* source);

    int createProgram();


public:

    bool init();

    void drawSelf(GLFWwindow* window);

    void destroy();
};

#endif /* triangle_v3_h */
